package org.jetlinks.community.device.entity;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.jetlinks.community.device.enums.ProtocolType;
import org.jetlinks.community.device.util.DateUtils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
public class PlayBackStreamParam {

    private String cameraIndexCode;

    private Integer recordLocation = 1;

    /**
     * 详见：
     * @see  ProtocolType
     */
    private String protocol = ProtocolType.hls.getValue();

    /**
     * 传输协议（传输层协议），0:UDP
     * 1:TCP
     * 默认是TCP
     * 注：GB28181 2011及以前版本只支持UDP传输
     */
    private Integer transmode = 1;

    private String beginTime;

    private String endTime;

    /**
     * 只可以调用一次
     */
    public void setHIKBeginTime() {
        LocalDateTime defaultTime = LocalDateTime.now().plusDays(-1);

        this.setBeginTime(DateUtils.yyyyMMddHHmmssToyyyyMMddTHHmmssXXX(this.beginTime, defaultTime));
    }

    /**
     * 只可以调用一次
     */
    public void setHIKEndTime() {
        LocalDateTime defaultTime = LocalDateTime.now();

        this.setEndTime(DateUtils.yyyyMMddHHmmssToyyyyMMddTHHmmssXXX(this.endTime, defaultTime));
    }
}
